package com.ali.resource.CompoentPage;


import com.ali.resource.ShareTools.BasicTools;
import com.ali.resource.ShareTools.TeaopenapiClient;
import com.aliyun.alidns20150109.Client;
import com.aliyun.alidns20150109.models.*;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DnsPublicZoneComponent {

    @Autowired
    private TeaopenapiClient teaopenapiClient;

    public com.aliyun.alidns20150109.Client getDnsClient() throws Exception {
        Config client = teaopenapiClient.getClient();
        client.setEndpoint("alidns.cn-hangzhou.aliyuncs.com");

        Client dnsClient = new Client(client);;
        return dnsClient;
    }

    public com.aliyun.alidns20150109.models.DescribeDomainRecordsRequest getDomainRecord(String DomainName){
        DescribeDomainRecordsRequest describeDomainRecordsRequest = new DescribeDomainRecordsRequest();
        describeDomainRecordsRequest.setDomainName(DomainName);
        return describeDomainRecordsRequest;
    }

    public com.aliyun.alidns20150109.models.DescribeDomainRecordsResponse getDomainRecordResponse(com.aliyun.alidns20150109.models.DescribeDomainRecordsRequest request) throws Exception {
        DescribeDomainRecordsResponse describeDomainRecordsResponse = this.getDnsClient().describeDomainRecordsWithOptions(request, teaopenapiClient.getRunTime());
        return describeDomainRecordsResponse;
    }

    public com.aliyun.alidns20150109.models.DescribeDomainsRequest getDomains(){
        DescribeDomainsRequest describeDomainsRequest = new DescribeDomainsRequest();
        describeDomainsRequest.setPageNumber(1L);
        describeDomainsRequest.setPageSize(100L);
        return describeDomainsRequest;
    }

    public com.aliyun.alidns20150109.models.DescribeDomainsResponse getDomainResponse() throws Exception {
        DescribeDomainsResponse describeDomainsResponse = this.getDnsClient().describeDomainsWithOptions(this.getDomains(), teaopenapiClient.getRunTime());
        return describeDomainsResponse;

    }


}
